package com.linzp.bishe.common;
import java.util.HashMap;

/**
 * @ClassName Result
 * @Description 与前端交互的包装类，加成功与失败
 * @Author LinZePeng
 * @Date 2021/11/1 10:14
 * @Version 1.0
 */
public class Result extends HashMap<String, Object> {

	private static final long serialVersionUID = 1L;
	/**
	 * @Description 消息码
	 */
	private static final String CODE = "code";

	/**
	 * @Description 附带的信息
	 */
	private static final String MSG = "msg";


	public static Result success() {
		Result result = new Result();
		result.put(CODE,"200");
		result.put(MSG,"成功");
		return result;
	}

	public static  Result success(String key,Object data) {
		Result result = new Result();
		result.put(CODE,"200");
		result.put(MSG,"成功");
		result.put(key,data);
		return result;
	}

	public static Result error(String code, String msg) {
		Result result = new Result();
		result.put(CODE,code);
		result.put(MSG,msg);
		return result;
	}
	public static Result error(String msg) {
		Result result = new Result();
		result.put(CODE,"400");
		result.put(MSG,msg);
		return result;
	}

}

